<template>
  <div class="info-space" v-bind:style="{ height: fullHeight + 'px', width: width + 'px' }">
    <div class="info-main">
      <!-- title -->
      <div class="title">hello word system</div>
      <!-- icon -->
      <div class="head-portrait">
        <div class="icon-box"></div>
      </div>
      <!-- info detail -->
      <div class="info-detail">
        <div class="info-item">用户名: {{userInfo.name}}</div>
        <div class="info-item">邮箱: {{userInfo.email}}</div>
        <div class="info-item">身份: {{userInfo.identity}}</div>
      </div>
      <!-- actions -->
      <div class="actions">
        <div class="actions-item">编辑信息</div>
        <div class="actions-item">修改密码</div>
        <div class="actions-item">切换账号</div>
        <div class="actions-item">退出登录</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    const that = this;
    window.onresize = () => {
      return (() => {
        window.fullHeight = document.documentElement.clientHeight;
        that.fullHeight = window.fullHeight;
      })();
    };
  },
  data() {
    return {
      fullHeight: document.documentElement.clientHeight,
      userInfo: {
        name: "User",
        email: "helloword@outlook.com",
        identity: "普通用户"
      }
    };
  },
  props: ["width"],
  watch: {
    fullHeight(val) {
      if (!this.timer) {
        this.fullHeight = val;
        this.timer = true;
        let that = this;
        setTimeout(function() {
          that.timer = false;
        }, 400);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.info-space {
  position: fixed;
  overflow: hidden;
  left: 0;
  top: 0;
  width: inherit;
  overflow: hidden;
  background-color: #454d55;
  border-right: 1px solid #343a40;
  z-index: 9;
}
.info-main {
  width: 240px;
  height: inherit;
  position: absolute;
  top: 0;
  right: 0;
}
.title {
  color: #eeeeee;
  border-bottom: 1px solid #343a40;
  font-size: 22px;
  line-height: 32px;
  font-weight: 900;
  padding: 15px 15px;
}
.head-portrait {
  margin: 15px auto;
}
.icon-box {
  margin: 0 auto;
  width: 128px;
  height: 128px;
  background-color: #eeeeee;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.2);
}
.info-detail {
  width: 240px;
  text-align: left;
  text-indent: 15px;
  color: #eeeeee;
  font-size: 16px;
  line-height: 36px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  padding-bottom: 30px;

  .info-item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.actions {
  // border-top: 1px solid transparent;
  box-sizing: border-box;
  width: 100%;
  text-align: center;
  color: #eeeeee;
  font-size: 16px;
  line-height: 40px;
  .actions-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }
  .actions-item:hover{
    background-color: rgba(0, 0, 0, 0.2);
  }
}
</style>
